<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!-- 公共头部部分 -->
<jsp:include page="_header.jsp"></jsp:include>
<!-- end -->
<title>${pageText }</title>
<meta name="keywords" content="H-ui.admin v3.1,H-ui网站后台模版,后台模版下载,后台管理系统模版,HTML后台模版下载">
<meta name="description" content="H-ui.admin v3.1，是一款由国人开发的轻量级扁平化网站后台模板，完全免费开源的网站后台管理系统模版，适合中小型CMS后台系统。">
</head>
<body>
<article class="page-container">
	<form class="form form-horizontal" id="form-article-add">
		<div class="row cl hidden">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>pageText：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="${pageText}" placeholder="" id="pageText" name="pageText">
			</div>
		</div>
		<div class="row cl hidden">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>id：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="${ct.courseTable_id }" placeholder="" id="id" name="id">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>教室：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<%-- <input type="text" class="input-text" value="${ct.classroom_fk_id }" placeholder="" id="classroom_fk_id" name="classroom_fk_id"> --%>
				<select name="classroom_fk_id" class="select">
					<option value="${ct.classroom_fk_id}">${ct.classroom_name }</option>
					<c:forEach var="cr" items="${crList }">
						<c:if test="${!empty  ct.classroom_fk_id }">
							<c:if test="${cr.classroom_id ne ct.classroom_fk_id }">
								<option value="${cr.classroom_id}">${ cr.classroom_name}</option>
							</c:if>
						</c:if>
						<c:if test="${empty  ct.classroom_fk_id }">
							<option value="${cr.classroom_id}">${ cr.classroom_name}</option>
						</c:if>
					</c:forEach>
				</select>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>班级：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<%-- <input type="text" class="input-text" value="${ct.class_fk_id }" placeholder="" id="class_fk_id" name="class_fk_id"> --%>
				<select id="courseClass" name="class_fk_id" class="select">
					<option value="${ct.class_fk_id}">${ct.class_name }</option>
					<c:forEach var="cc" items="${ccList }">
						<c:if test="${!empty  ct.class_fk_id  }">
							<c:if test="${cc.class_id ne ct.class_fk_id  }">
								<option value="${cc.class_id}">${ cc.class_name}</option>
							</c:if>
						</c:if>
						<c:if test="${empty  ct.class_fk_id  }">
							<option value="${cc.class_id}">${ cc.class_name}</option>
						</c:if>
					</c:forEach>
				</select>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>课程章节：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<%-- <input type="text" class="input-text" value="${ct.course_fk_id }" placeholder="" id="course_fk_id" name="course_fk_id"> --%>
				<select id="chapter" name="course_fk_id" class="select">
					<option value="${c.course_fk_id}">${ct.chapter_name }</option>
					<c:forEach var="c" items="${cList }">
						<c:if test="${!empty  ct.course_fk_id  }">
							<c:if test="${c.course_id ne ct.course_fk_id  }">
								<option value="${c.course_id}">${ c.chapter_name}</option>
							</c:if>
						</c:if>
						<c:if test="${empty  ct.course_fk_id  }">
							<option value="${c.course_id}">${ c.chapter_name}</option>
						</c:if>
					</c:forEach>
				</select>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>上课时间：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" onfocus="WdatePicker({minDate:'%y-%M-{%d+1}'})" value='<fmt:formatDate value="${ct.courseTable_Date}" pattern="yyyy-MM-dd"/>' id="courseTable_Date" name="courseTable_Date" class="input-text Wdate" style="width:120px;">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>上课时段：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<select name="courseTable_teachDate" class="select">
					<c:if test="${empty ct.courseTable_teachDate }">
							<option value="上午">上午</option>
							<option value="下午">下午</option>
					</c:if>
					<c:if test="${ct.courseTable_teachDate eq '上午' }">
							<option value="上午">上午</option>
							<option value="下午">下午</option>
					</c:if>
					<c:if test="${ct.courseTable_teachDate eq '下午' }">
							<option value="下午">下午</option>
							<option value="上午">上午</option>
					</c:if>
				</select>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>教员：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<%-- <input type="text" class="input-text" value="${ct.teacher_fk_id }" placeholder="" id="teacher_fk_id" name="teacher_fk_id"> --%>
				<select name="teacher_fk_id" class="select">
					<option value="${ct.teacher_fk_id}">${ct.teacher_name }</option>
					<c:forEach var="tc" items="${tcList }">
						<c:if test="${!empty  ct.teacher_fk_id }">
							<c:if test="${tc.teacher_id ne ct.teacher_fk_id }">
								<option value="${tc.teacher_id}">${ tc.teacher_name}</option>
							</c:if>
						</c:if>
						<c:if test="${empty  ct.teacher_fk_id }">
							<option value="${tc.teacher_id}">${ tc.teacher_name}</option>
						</c:if>
					</c:forEach>
				</select>
			</div>
		</div>
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
				<button onClick="article_save_submit();" class="btn btn-primary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i> 提交</button>
				<!-- <button id="btn" class="btn btn-primary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i> 提交</button> -->
			</div>
		</div>
	</form>
</article>
<!-- 公共修改，增加页脚部分 -->
<jsp:include page="_footer-add-update.jsp"></jsp:include>
<!-- end -->
<script type="text/javascript">
$("#courseClass").change(function(){
	var id=$(this).val();
	$.ajax({
			type:"post",
			url:"${pageContext.request.contextPath }/educCourseTable/chapterList",
			data:{
				id:id
			},
			success:function(data){
				option=null;   
                $.each(data,function(i,c){
                   option += "<option value='"+c.course_id+"'>"+c.chapter_name+"</option>"  
                }); 
                 $("#chapter").html(option);
			},
			error:function(data){
				layer.msg('error!',{icon:2,time:1000});
			}
		});
});

$(function(){
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});
	
	//表单验证
	$("#form-article-add").validate({
		rules:{
			classroom_fk_id:{
				required:true,
			},
			class_fk_id:{
				required:true,
			},
			course_fk_id:{
				required:true,
			},
			courseTable_Date:{
				required:true,
			},
			teacher_fk_id:{
				required:true,
			},
		},
		onkeyup:false,
		focusCleanup:true,
		success:"valid",
		submitHandler:function(form){
            $(form).ajaxSubmit({
                type: "post",
                url: "${pageContext.request.contextPath }/educCourseTable/update",
                success: function(data){
                	if(data.error==""||data.error=="1"||data.error=="0"){
                		layer.msg('添加成功!', {icon : 1,time : 1000});
                		//获取父层  
	                    var index = parent.layer.getFrameIndex(window.name);  
	                    //刷新父层  
	                    parent.location.reload();  
	                    //关闭弹出层  
	                    parent.layer.close(index);
                	}else{
                		layer.msg('输入信息重复（'+data.error+'），请核对!', {icon : 2,time : 1000});
                	}
                }, 
               error: function(XmlHttpRequest, textStatus, errorThrown){  
                    layer.msg('ERROR!',{icon:2,time:1000});  
                }  
            });  
        }  
		
	});
});
</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>






